import java.io.IOException;
import java.net.Socket;
import java.util.Date;

/**
 * @author jason.tang
 * @create 2018-11-28 10:11
 * @description
 */
public class IOClient {

    public static void main(String[] args) throws IOException, InterruptedException {
        new Thread(new Runnable() {
            public void run() {
                Socket socket;
                try {
                    socket = new Socket("127.0.0.1", 8878);
                    while (true) {
                        socket.getOutputStream().write((new Date() + ": hello, world!").getBytes());
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}